<?php
namespace app\admin\model;
use think\Model;
use think\Db;
// 用户表模型
class Login extends Model
{
	public function login($data){
		$captcha = new \think\captcha\Captcha();//验证码类
        if (!$captcha->check($data['code'])) {
            return 4;
        } 
        $user=Db::name('user')->where('username','=',$data['username'])->find();
        if ($user) {
        	if ($user['password']==md5($data['password'])) {
        		session('username',$user['username']);
        		session('id',$user['id']);
        		return 3;//信息正确
        	}else{
        		return 2;//密码或用户名不正确
        	}
        }else{
        	return 1;//用户不存在
        }
	}
}